package org.example.runningforum.config;

import lombok.extern.slf4j.Slf4j;


import org.example.runningforum.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;


@Slf4j
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    //使用列表
    private List exclude = Arrays.asList(
            "/**/*.html",
            "/running-editormd/**",
            "/css/**",
            "/js/**",
            "/pic/**",
            "/user/login",
            "/user/enroll"
    );
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(exclude);
    }
}
